package org.csu.assemblyroom.controller;

import org.csu.assemblyroom.common.CommonResponse;
import org.csu.assemblyroom.entity.Room;
import org.csu.assemblyroom.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 会议室的增删改查
 */
@RestController
@RequestMapping("/room")
public class RoomController {

    @Autowired
    private RoomService roomService;

    @GetMapping("/getAllroom")
    public CommonResponse<List<Room>> getAllRoom(){
        return roomService.getAllRooms();
    }
    @GetMapping("/getRoomById/{id}")
    public CommonResponse<Room> getRoomById(@PathVariable("id") String roomnumber){

        return roomService.getRoomById(roomnumber);
    }
    @DeleteMapping("/deleteRoomById/{id}")
    public CommonResponse<List<Room>> deleteRoomById(@PathVariable("id") String roomnumber){

        return roomService.deleteRoomById(roomnumber);
    }
    @PostMapping("/addRoom")
    public CommonResponse<List<Room>> deleteRoomById(@RequestBody Room room){
        return roomService.addRoom(room);
    }

    @PutMapping("/bookRoomById/{id}")
    public CommonResponse<Room> bookRoomById(@PathVariable("id") String roomnumber){

        return roomService.bookRoomById(roomnumber);
    }
}